﻿<UserControl x:Class="Subtitles.MydraSubtitlesSelection.MydraSubtitlesSelectionView"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300">

    <StackPanel>
        <TextBlock FontSize="12" FontWeight="Black" Text="{Binding FileHandler.Path}"/>
        <TabControl Name="ProviderSelector" ItemsSource="{Binding ResultsPerSubtitlesProvider}">
            <TabControl.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal" >
                        <TextBlock Text="{Binding ProviderName}"/>
                        <TextBlock Text=" *">
                            <TextBlock.Style>
                                <Style TargetType="TextBlock">
                                    <Setter Property="Visibility" Value="Visible" />
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding IsBusy}" Value="False">
                                            <Setter Property="Visibility" Value="Collapsed" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style>
                        </TextBlock>
                    </StackPanel>
                </DataTemplate>
            </TabControl.ItemTemplate>
            <TabControl.ContentTemplate>
                <DataTemplate>
                    <ListView ItemsSource="{Binding Subtitles}" >
                        <ListView.View>
                            <GridView>
                                <GridViewColumn Header="URI" DisplayMemberBinding="{Binding Uri}" />
                                <GridViewColumn Header="Name"  DisplayMemberBinding="{Binding Name}" />
                                <GridViewColumn Header="Language"  DisplayMemberBinding="{Binding Language}" />
                                <GridViewColumn Header="Download">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <Button Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}, Path=DataContext.LoadSubtitlesCommand}" CommandParameter="{Binding Path=.}" Content="Plop"/>
                                            <!--<Button Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}, Path=DataContext.LoadSubtitlesCommand}" CommandParameter="{Binding}">Download !</Button>-->
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                            </GridView>
                        </ListView.View>
                    </ListView>
                </DataTemplate>
            </TabControl.ContentTemplate>
        </TabControl>
        <Button Command="{Binding LoadSubtitlesCommand}">Load Sub</Button>
    </StackPanel>
</UserControl>